﻿<Page x:Class="ComicReader.Views.ConverterPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:IO="clr-namespace:System.IO;assembly=mscorlib"
    xmlns:Helpers="clr-namespace:ComicReader.Helpers"
    xmlns:Controllers="clr-namespace:ComicReader.Controllers"
    MinHeight="300" 
    MinWidth="300" 
    Height="Auto" Width="Auto"
    Title="ConverterPage">
    <Page.Resources>
        <ObjectDataProvider x:Key="Drives" MethodName="GetDrives" ObjectType="{x:Type IO:DriveInfo}" />
        
        <Helpers:GetFileSystemInformationConverter x:Key="getFileSystemInformationConverter"/>
        <Helpers:GetFileInformationIconConverter x:Key="getFileInformationIconConverter"/>
        
        <HierarchicalDataTemplate DataType="{x:Type IO:DriveInfo}" ItemsSource="{Binding Converter={StaticResource getFileSystemInformationConverter}}">
            <StackPanel Orientation="Horizontal">
                <Image Width="20" Height="20" Stretch="Fill" Source="/Content/Images/diskdrive.png" />
                <TextBlock Text="{Binding Name}" Margin="5,0,0,0" />
            </StackPanel>
        </HierarchicalDataTemplate>

        <HierarchicalDataTemplate DataType="{x:Type IO:DirectoryInfo}" ItemsSource="{Binding Converter={StaticResource getFileSystemInformationConverter}}">
            <StackPanel Orientation="Horizontal">
                <Image Width="20" Height="20" Stretch="Fill" Source="/Content/Images/folder.png" />
                <TextBlock Text="{Binding Name}" Margin="5,0,0,0" />
            </StackPanel>
        </HierarchicalDataTemplate>

        <HierarchicalDataTemplate DataType="{x:Type IO:FileInfo}" ItemsSource="{Binding Converter={StaticResource getFileSystemInformationConverter}}">
            <StackPanel Orientation="Horizontal">
                <Image Width="20" Height="20" Stretch="Fill" Source="{Binding Converter={StaticResource getFileInformationIconConverter}}" />
                <TextBlock Text="{Binding Name}" Margin="5,0,0,0" />
            </StackPanel>
        </HierarchicalDataTemplate>

    </Page.Resources>
    <Grid DataContext="{StaticResource Drives}">
        <TreeView ItemsSource="{Binding}" />
    </Grid>
</Page>
